package com.aotain.common;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ZkKafkaConfig {

//	private String hbase_zkList;
	private String zkConn ;
	private String zkConn_;
	private String mushroomServer;
	private String filterIPs;
	private String brokerList;
//	private String topic;
//	private String brokersRoot;
	private String sqlinjection;
	private String mongodbHost;
	private int mongodbPort = 27017;
	private String flinkmode = "KAFKA";
	private String flinksocketport = "9988|9989";
	private String flinkSocketIP = "192.168.5.28";
	private String mongodbDBName = "sds";
	
	public ZkKafkaConfig(String config) {
		Properties prop = new Properties();
		try {
			InputStream in = new FileInputStream(config);
			prop.load(in);  
			mushroomServer = prop.getProperty("mushroomserver");
			zkConn = prop.getProperty("zkConn");
			zkConn_ = prop.getProperty("zkConn_");
			brokerList = prop.getProperty("brokerlist");
			
			sqlinjection = prop.getProperty("sqlinjection");
			mongodbHost = prop.getProperty("mongodb.ip");
			if(prop.getProperty("mongodb.port")!=null)
				mongodbPort = Integer.parseInt(prop.getProperty("mongodb.port"));
			
			if(prop.getProperty("mongodb.dbname")!=null)
				mongodbDBName = prop.getProperty("mongodb.dbname");
			
			if(prop.getProperty("flink.source") != null)
				flinkmode = prop.getProperty("flink.source");
			
			if(prop.getProperty("flink.socketport") != null)
				flinksocketport = prop.getProperty("flink.socketport");
			
			if(prop.getProperty("flink.socketip") != null)
				flinkSocketIP = prop.getProperty("flink.socketip");
			
			
			
			if(mushroomServer != null)
				mushroomServer = mushroomServer.trim();
			
			if(zkConn != null)
				zkConn = zkConn.trim();
			
			if(brokerList != null)
				brokerList = brokerList.trim();
			
			if(sqlinjection != null)
				sqlinjection = sqlinjection.trim();
			
			if(mongodbHost != null)
				mongodbHost = mongodbHost.trim();
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return;
		}
	}
	
	public String getZkConn_() {
		return zkConn_;
	}

	public String getMushroomServer() {
		return mushroomServer;
	}
	
	public String getSQLInjection() {
		return sqlinjection;
	}
	
	public String getZkConnServer(){
		return zkConn;
	}
	
	public String getFilterIPss(){
		return filterIPs;
	}
	
	public String getBrokerList(){
		return brokerList;
	}
	
	public String getMongoDBIP() {
		return mongodbHost;
	}
	
	public Integer getMongoDBPort() {
		return mongodbPort;
	}
	
	public String getFlinkMode() {
		return flinkmode;
	}
	
	/**
	 * Flink Socket 接收数据端口 PORT1|PORT2|PORT3
	 * @return
	 * @Description:
	 */
	public String getFlinkSocketPort() {
		return flinksocketport;
	}
	
	/**
	 * Flink Socket 接收数据IP
	 * @return
	 * @Description:
	 */
	public String getFlinkSocketIP() {
		return flinkSocketIP;
	}
	
	public String getMongoDBName() {
		return mongodbDBName;
	}
}
